//
//  TabbaoController.m
//  AntsExpress
//
//  Created by Home on 18/1/16.
//  Copyright © 2016年 slccper. All rights reserved.
//

#import "TabbaoController.h"
#import "TaobaoCell.h"
#import "TaobaoViewController.h"
@interface TabbaoController ()<UITableViewDataSource,UITableViewDelegate>
{
    NSMutableArray *dataList;
}
@property (weak, nonatomic) IBOutlet UITableView *tableView;

@end

@implementation TabbaoController

- (void)viewDidLoad {
    [super viewDidLoad];
    //    dataList = [NSMutableArray array];
    //    [dataList addObjectsFromArray:@[@"珠海",@"澳門",@"氹仔"]];
    self.tableView.sectionHeaderHeight=40;
    self.tableView.separatorStyle=UITableViewCellSeparatorStyleNone;
    self.tableView.tableFooterView=[[UIView alloc]init];
    self.title = @"淘寶收貨地址";
    // Do any additional setup after loading the view from its nib.
}
-(void)getWebData
{
    if ([clsOtherFun CheckNetworkStatus:YES]) {
        [clsOtherFun showLoadingView:@"正在獲取數據..."];
        if (ants) {
            ants.delegate=nil;
            ants=nil;
        }
        ants = [[clsAntsService alloc]init];
        ants.delegate=self;
        [ants GetTaoBaoAdress];
    }
}
#pragma mark - UITableView
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return dataList.count;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"TaobaoCell";
    
    TaobaoCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[NSBundle mainBundle]loadNibNamed:@"TaobaoCell" owner:self options:nil]lastObject];
        cell.accessoryType = UITableViewCellAccessoryNone;
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
//        cell.parentViewController=self;
    }
    NSDictionary *dic = [dataList objectAtIndex:indexPath.section];
    [cell.lbTitle setText:[dic objectForKey:@"Name"]];
    //    cell.imageView.image=[clsOtherFun createImageWithColor:[UIColor blueColor]];
//    [cell setDataWith:dic];
    return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSDictionary *dic = [dataList objectAtIndex:indexPath.section];
    TaobaoViewController *taobao = [[TaobaoViewController alloc]initWithNibName:@"TaobaoViewController" bundle:nil];
    taobao.isBack =YES;
    taobao.dic=dic;
    [self.navigationController pushViewController:taobao animated:YES];
}
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    return [[UIView alloc]init];
}
-(void)getAntsDataFail:(NSInteger)type
{
    [clsOtherFun hideLoadingView];
    [clsOtherFun ShowMsgWithNoData];
}
-(void)getAntsDataSuccess:(NSInteger)type :(NSMutableDictionary *)pDictionary
{
    [clsOtherFun hideLoadingView];
    NSDictionary *dic = [pDictionary objectForKey:@"data"];
    NSString *status = [dic objectForKey:@"status"];
    if ([status integerValue]==200) {
        dataList = [dic objectForKey:@"data"];
        [self.tableView reloadData];
    }else{
        [clsOtherFun ShowMsgWithNoData];
    }
   
}
@end
